package com.luoy.order;

import org.apache.hadoop.io.WritableComparable;
import org.apache.hadoop.io.WritableComparator;

/**
 * 比较orderId，让reduce把相同id 当作一个处理
 */
public class OrderGroupingCompartor extends WritableComparator {

	//写一个空参构造
	public OrderGroupingCompartor(){
		super(OrderBean.class, true);
	}
	
	//重写比较方法
	@Override
	public int compare(WritableComparable a, WritableComparable b) {
		//强制转换
		OrderBean aBean = (OrderBean) a;
		OrderBean bBean = (OrderBean) b;
		//比较两个id
		return aBean.getOrderId().compareTo(bBean.getOrderId());
	}
}
